﻿@model diag_sum
@helper RenderTree(diag_sum cata, Func<diag_sum, string> idf, Func<diag_sum, string> titlef, Func<diag_sum, IEnumerable<diag_sum>> subf)
    {
        var idstr = idf.Invoke(cata); var titlestr = titlef.Invoke(cata);
        var sublist = subf.Invoke(cata);
    <li class="closed">
        @if(idstr=="9999")
        {
            <div class="catalog-title">备件或人工设备</div>
        }
        else
        {
        <div>@(titlestr)
            <span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="#" onclick="var e=$('#ts_SrcBJ').first();e.val(e.val()+'@(titlestr)'+'@(idstr.EndsWith("00") ? " " : " ")');return false;">
                添加&gt;&gt;</a> </span>
        </div>
        }
        @if (sublist.Count() > 0)
        {
            <ul id="s@(idstr)">
                @foreach (var subcata in sublist)
                {
                    @RenderTree(subcata, idf, titlef, subf)
                }
            </ul>
        }
    </li>
}

<div style="height: 400px; overflow: auto;">
    <ul id="treeselectroot">
        @RenderTree(Model, v => v.diag_code, v => v.diag_name, v => v.diag_sum1)
    </ul>
</div>
<div>
        型号：<select id="unitsizesel">
            @for (int i = 4; i <= 42; i++)
            {
                <option>#@(i)mm型</option>
            }
        </select>
    <a href="#" onclick="var e=$('#ts_SrcBJ').first();e.val(e.val()+$('#unitsizesel').val()+';');return false;">
        添加&gt;&gt;</a>
</div>
<script type="text/javascript">
    $(function () {
        $("#treeselectroot").treeview();
    });
</script>
